using System;
using System.Text;
using System.Runtime.InteropServices;

namespace VABMobile.print
{
    #region LKPrint class declaration
    public class LKPrint
    {
        public const string SEWOODIR = "SEWOOP20.dll";

        private LKPrint() { }

        //LUKHAN print method define
        [DllImport(SEWOODIR, SetLastError = true, EntryPoint = "OpenPort")]
        public static extern Int32 OpenPort(string PortName, Int32 BaudRate);

        [DllImport(SEWOODIR, SetLastError = true, EntryPoint = "ClosePort")]
        public static extern Int32 ClosePort();

        [DllImport(SEWOODIR, SetLastError = true, EntryPoint = "PrintNormal")]
        public static extern Int32 PrintNormal(string Data);

        [DllImport(SEWOODIR, SetLastError = true, EntryPoint = "PrintText")]
        public static extern Int32 PrintText(string Data, Int32 Alignment, Int32 Options, Int32 TextSize);

        [DllImport(SEWOODIR, SetLastError = true, EntryPoint = "PrintString")]
        public static extern Int32 PrintString(string Data);

        [DllImport(SEWOODIR, SetLastError = true, EntryPoint = "PrintBitmap")]
        public static extern Int32 PrintBitmap(string BitmapFile, Int32 Alignment, Int32 Mode);

        [DllImport(SEWOODIR, SetLastError = true, EntryPoint = "PrintBarCode")]
        public static extern Int32 PrintBarCode(string Data, Int32 Symbology, Int32 Height, Int32 Width, Int32 Alignment, Int32 TextPosition);

        [DllImport(SEWOODIR, SetLastError = true, EntryPoint = "PrinterCheck")]
        public static extern Int32 PrinterCheck();

        [DllImport(SEWOODIR, SetLastError = true, EntryPoint = "status")]
        public static extern Int32 status();

        [DllImport(SEWOODIR, SetLastError = true, EntryPoint = "LineFeed")]
        public static extern Int32 LineFeed(Int32 LFCount);

        [DllImport(SEWOODIR, SetLastError = true, EntryPoint = "PrintNVBitmap")]
        public static extern Int32 PrintNVBitmap(Int32 NVImageNumber);

        [DllImport(SEWOODIR, SetLastError = true, EntryPoint = "MSRSelectTrack")]
        public static extern Int32 MSRSelectTrack(Int32 SelectTrack);

        [DllImport(SEWOODIR, SetLastError = true, EntryPoint = "MSRReadTrack")]
        public static extern Int32 MSRReadTrack(byte[] DataTrack1, byte[] DataTrack2, byte[] DataTrack3);

        [DllImport(SEWOODIR, SetLastError = true, EntryPoint = "MSRReadTrackDual")]
        public static extern Int32 MSRReadTrackDual(byte[] DataTrack1, byte[] DataTrack2, byte[] DataTrack3, byte[] DataTrack4);

        [DllImport(SEWOODIR, SetLastError = true, EntryPoint = "MSRReadCancel")]
        public static extern Int32 MSRReadCancel();

        [DllImport(SEWOODIR, SetLastError = true, EntryPoint = "PrintText2Image")]
        public static extern Int32 PrintText2Image(string TextData, string FontFace, Int32 FontStyle, Int32 FontSize, Int32 Alignment);

        //Method return value
        public const Int32 LK_SUCCESS = 0;
        public const Int32 LK_CREATE_ERROR = 1;
        public const Int32 LK_NOT_OPENED = 2;
        public const Int32 LK_FAIL = -1;

        // Printer Status flag
        public const Int32 LK_STS_PRINTEROFF = 128;
        public const Int32 LK_STS_MSR_READ = 64;
        public const Int32 LK_STS_PAPER_EMPTY = 32;
        public const Int32 LK_STS_COVER_OPEN = 16;
        public const Int32 LK_STS_BATTERY_LOW = 8;
        public const Int32 LK_STS_NORMAL = 0;

        // Alignment Code
        public const Int32 LK_ALIGNMENT_LEFT = 0;
        public const Int32 LK_ALIGNMENT_CENTER = 1;
        public const Int32 LK_ALIGNMENT_RIGHT = 2;

        // Bitmap Size
        public const Int32 LK_BITMAP_NORMAL = 0;
        public const Int32 LK_BITMAP_WIDTH_DOUBLE = 1;
        public const Int32 LK_BITMAP_HEIGHT_DOUBLE = 2;
        public const Int32 LK_BITMAP_WIDTH_HEIGHT_DOUBLE = 3;

        // Bitmap Image Mode
        public const Int32 LK_BITMAP_NO_DITHER = 0;
        public const Int32 LK_BITMAP_ERROR_DIFFUSION = 1;
        public const Int32 LK_BITMAP_ORDERED_DITHER = 2;


        //Text Attribute
        //Font Attribute default value : not Bold, FontA, not Underline, not reverse
        public const Int32 LK_FNT_DEFAULT = 0;
        public const Int32 LK_FNT_FONTB = 1;
        public const Int32 LK_FNT_BOLD = 8;
        public const Int32 LK_FNT_UNDERLINE = 128;

        // Text Size Attribute
        public const Int32 LK_TXT_1WIDTH = 0;
        public const Int32 LK_TXT_2WIDTH = 16;
        public const Int32 LK_TXT_3WIDTH = 32;
        public const Int32 LK_TXT_4WIDTH = 48;
        public const Int32 LK_TXT_5WIDTH = 64;
        public const Int32 LK_TXT_6WIDTH = 80;
        public const Int32 LK_TXT_7WIDTH = 96;
        public const Int32 LK_TXT_8WIDTH = 112;

        public const Int32 LK_TXT_1HEIGHT = 0;
        public const Int32 LK_TXT_2HEIGHT = 1;
        public const Int32 LK_TXT_3HEIGHT = 2;
        public const Int32 LK_TXT_4HEIGHT = 3;
        public const Int32 LK_TXT_5HEIGHT = 4;
        public const Int32 LK_TXT_6HEIGHT = 5;
        public const Int32 LK_TXT_7HEIGHT = 6;
        public const Int32 LK_TXT_8HEIGHT = 7;

        // Barcode
        public const Int32 LK_BCS_PDF417 = 200;
        public const Int32 LK_BCS_MAXICODE = 201;
        public const Int32 LK_BCS_QRCODE = 202;
        public const Int32 LK_BCS_DATAMATRIX = 203;

        public const Int32 LK_BCS_UPCA = 101;
        public const Int32 LK_BCS_UPCE = 102;
        public const Int32 LK_BCS_EAN8 = 103;
        public const Int32 LK_BCS_EAN13 = 104;
        public const Int32 LK_BCS_JAN8 = 105;
        public const Int32 LK_BCS_JAN13 = 106;
        public const Int32 LK_BCS_ITF = 107;
        public const Int32 LK_BCS_Codabar = 108;
        public const Int32 LK_BCS_Code39 = 109;
        public const Int32 LK_BCS_Code93 = 110;
        public const Int32 LK_BCS_Code128 = 111;
        public const Int32 LK_BCS_3OF5 = 112;
        // Barcode text position
        public const Int32 LK_HRI_TEXT_NONE = 0;
        public const Int32 LK_HRI_TEXT_ABOVE = 1;
        public const Int32 LK_HRI_TEXT_BELOW = 2;

        // MSR
        public const Int32 LK_CHECKSUM_ERROR = 1;
        public const Int32 LK_TIMEOUT_ERROR = 2;
    }
    #endregion

}
